package demo3;

import java.util.Comparator;

public class Student implements Comparator<Student> {

    public String name;
    public int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +"}";
    }

    @Override
    public int compare(Student o1, Student o2) {
        return o1.age-o2.age;
    }
}
